/* let a = '45645645665165165165';
let ap = a.split("");
//console.log(ap);
//split "hahaha"=> [h,a,h,a,h,a] 
let rever = ap.reverse();
//console.log(rever); 
//join 
let res = rever.join('');
console.log(res);
let a = [1, 2, 2, 3, 4, 5, 6, 7]
let res = a.reduce(a)
console.log(res); */
const array1 = [1, 2, 3, 4];
const reducer = (accumulator, currentValue) => accumulator + currentValue;

// 1 + 2 + 3 + 4
console.log(array1.reduce(reducer));
// expected output: 10

// 5 + 1 + 2 + 3 + 4
console.log(array1.reduce(reducer, 5));